package utils

import (
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/config"
)

var (
	GServerName  string //服务器名称
	GServerAddr  string //服务器ip地址
	GServerPort  string //服务器端口
	GRedisAddr   string //redis ip地址
	GRedisPort   string //redis port端口
	GRedisDbnum  string //redis db 编号
	GMysqlAddr   string //mysql ip 地址
	GMysqlPort   string //mysql 端口
	GMysqlDbname string //mysql db name
	GConsulAddr  string //consul ip地址
	GConsulPort  string //consul port端口
	GFastdfsPort string //fastdfs port端口
)

func InitConfig() {
	//从配置文件读取配置信息
	///如果项目迁移需要修改
	appconf, err := config.NewConfig("ini", "./conf/app.conf")
	//appconf, err := config.NewConfig("ini", "/Users/jackli/git/ihome/conf/app.conf")
	if err != nil {
		beego.Debug(err)
		return
	}
	GServerName = appconf.String("servername")
	GServerAddr = appconf.String("httpaddr")
	GServerPort = appconf.String("httpport")
	GRedisAddr = appconf.String("redisaddr")
	GRedisPort = appconf.String("redisport")
	GRedisDbnum = appconf.String("redisdbnum")
	GMysqlAddr = appconf.String("mysqladdr")
	GMysqlPort = appconf.String("mysqlport")
	GMysqlDbname = appconf.String("mysqldbname")
	GConsulAddr = appconf.String("consuladdr")
	GConsulPort = appconf.String("consulport")
	GFastdfsPort = appconf.String("fastdfsport")

	return
}

func init() {
	InitConfig()
}
